{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "13f7c0e4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "账号：doggie\n",
      "密码：10234\n",
      "账号不存在或密码不正确！请重新输入！您还有2次尝试的机会\n",
      "账号：doggie\n",
      "密码：20021007\n",
      "登录成功~欢迎doggie\n"
     ]
    }
   ],
   "source": [
    "user01 = \"doggie\"\n",
    "password01 = \"20021007\"\n",
    "\n",
    "for i in range(3,0,-1):\n",
    "    username = input(\"账号：\")\n",
    "    password = input(\"密码：\")\n",
    "    if user01 == username and password01 == password:\n",
    "        print(\"登录成功~欢迎\"+username)\n",
    "        break\n",
    "    else:\n",
    "        if i>1:\n",
    "            print(\"账号不存在或密码不正确！请重新输入！您还有\"+str(i-1)+\"次尝试的机会\")\n",
    "        else:\n",
    "            print(\"账号不存在或密码不正确！请1小时后再来尝试\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "f0474302",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-----商品列表-----\n",
      "['1:BTS 花樣年華PT.1，价格：69元', '2:BTS 花樣年華PT.2，价格：69元', '3:BTS LOVE YOURSELF承HER，价格：78元', '4:BTS LOVE YOURSELF转TEAR，价格：85元', '5:BTS LOVE YOURSELF結ANSWER，价格：92元']\n",
      "请输入您的昵称：doggie\n",
      "您的支付宝余额为：(若要退出请输入H):29\n",
      "您选择购买的商品编号是：3\n",
      "你所选择的商品价格为¥78\n",
      "余额不足，购买失败\n",
      "您购买的商品：3:BTS LOVE YOURSELF承HER，价格：78元\n",
      "您还有-49元\n"
     ]
    }
   ],
   "source": [
    "goods = [\"1:BTS 花樣年華PT.1，价格：69元\",\"2:BTS 花樣年華PT.2，价格：69元\",\"3:BTS LOVE YOURSELF承HER，价格：78元\",\"4:BTS LOVE YOURSELF转TEAR，价格：85元\",\"5:BTS LOVE YOURSELF結ANSWER，价格：92元\"]\n",
    "price = [69, 69, 78, 85, 92]\n",
    "print(\"-----商品列表-----\")\n",
    "print(goods)\n",
    "name = input(\"请输入您的昵称：\")\n",
    "money = input(\"您的支付宝余额为：\"'(若要退出请输入H):')\n",
    "while True:\n",
    "    if money == \"H\":\n",
    "        break\n",
    "    buy = input(\"您选择购买的商品编号是：\")\n",
    "    num = int(buy)\n",
    "    goodsbuy_list = goods[num - 1]\n",
    "    goodsbuy_price = price[num - 1]\n",
    "    print(\"你所选择的商品价格为¥\" + str(goodsbuy_price))\n",
    "    if int(money) >= goodsbuy_price:\n",
    "        print(\"购买成功\") \n",
    "    elif int(money) < goodsbuy_price:\n",
    "        print(\"余额不足，购买失败\")\n",
    "    money = int(money)\n",
    "    money -= goodsbuy_price\n",
    "    print(f\"您购买的商品：{goodsbuy_list}\\n您还有{money}\"+\"元\")\n",
    "    break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5018a39c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f3d94ff4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c5b3f13d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "14e95b8d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cc370df3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5136b60d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8031f3f3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "092734f0",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
